package com.kbbywyclient.ui.adapter.base;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import java.util.List;

/**
 * User: Heaven
 * Date: 2017-04-10
 * Time: 15:23
 * Description: BaseAdapter
 */
public abstract class BaseLvAdapter<T> extends android.widget.BaseAdapter {
    public static final int TYPE_NO_DATA=1;
    public static final int TYPE_NORMAL=0;
    private Context mContext;
    private int mItemLayout;
    public List<T> mList;
    public LayoutInflater mInflater; // 填充

    public BaseLvAdapter(Context context, int itemLayout, List<T> list) {
        this.mContext = context;
        this.mItemLayout = itemLayout;
        this.mList = list;
        this.mInflater = LayoutInflater.from(context);
    }

    protected BaseLvAdapter() {
    }

    @Override
    public int getCount() {
//        return mList == null ? 0 : mList.size();
        return mList == null? 0 : mList.size();
    }

    @Override
    public T getItem(int position) {
        return mList == null? null : mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    protected Context getContext() {
        return mContext;
    }

    protected View getItemView() {
        return mInflater.inflate(mItemLayout, null);
    }
}
